package edu.friday.model.vo;

import edu.friday.model.SysRole;
import edu.friday.model.SysUser;
import jakarta.persistence.Column;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;

import java.io.Serializable;
import java.time.Instant;
import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysUserVo implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;

    @Size(min = 0,max = 30,message = "用户名长度不能超过30字符")
    private String userName;

    @Size(min = 0,max = 30,message = "用户名长度不能超过30字符")
    private String nickName;

    private String userType;

    @Email(message = "邮箱格式不正确")
    @Size(min = 0,max = 50,message = "邮箱长度不能超过50字符")
    private String email;

    @Size(min = 0,max = 11,message = "邮箱长度不能超过11字符")
    private String phonenumber;

    private Character sex;

    private String avatar;

    private String password;

    private Character status;

    private Character delFlag;

    private String loginIp;

    private Instant loginDate;

    private String createBy;

    private Date createTime;

    private String updateBy;

    private Date updateTime;

    private String remark;

    private List<SysRole> roles;

    private Long [] roleIds;

    public SysUserVo(Long id) {
        this.id = id;
    }

    public boolean isAdmin() {
        return isAdmin(this.id);
    }

    public static boolean isAdmin(Long id) {
        return id !=null && id == 1L;
    }
}
